package com.ruoyi.central.enums;

import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.ruoyi.common.config.jackson.IEnumDeserializer;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.bean.EnumUtils;
import lombok.Getter;

/**
 * @Classname ProductMaterialType
 * @Author: sunluquan
 * @Date: 2022/4/12 12:06
 * @Description TODO
 * 产品物料类型枚举
 */
@Getter
@JsonDeserialize(using = IEnumDeserializer.class)
public enum ProductMaterialType implements IEnum<Integer> {

    PART(1,"零件"),
    SEMI_FINISHED_PRODUCT(2,"半成品"),
    FINISHED_PRODUCT(3,"成品");

    @JsonValue
    private final int value;
    private final String info;

    ProductMaterialType(int value, String info)
    {
        this.value = value;
        this.info = info;
    }
    @Override
    public Integer getValue()
    {
        return value;
    }

    public String getInfo()
    {
        return info;
    }

    @Override
    public String toString() {
        return Convert.toStr(this.value);
    }

    public static <E extends Enum> E toEnum(Integer value) {
        return (E) EnumUtils.toEnum(ProductMaterialType.class,value);
    }
}
